<template>
	<view>
		<view>
			<navitop>
				<i class="iconfont" slot="left-slot" @click="outlot">&#xe667;</i>
				<span slot="center-slot">设置</span>
				<!-- <i class="iconfont " slot="right-slot" @click="add">确定</i> -->
			</navitop>
		</view>
		<view :style="'padding-top:' + nv_height + ';'"  class='public_other'>
			<div class="public_other_list" @click="set_security">
				<div class="public_other_left">账号与安全</div>
				<div class="public_other_right"><i class="iconfont icon-changyongtubiao-xianxingdaochu-zhuanqu-"></i></div>
			</div>
			<div class="public_other_list" @click="set_equipment">
				<div class="public_other_left">设备型号</div>
				<div class="public_other_right">{{equip_data}}</div>
			</div>
			<div class="out_bottom" @click="email_class">
				<div class="out_dologin">退出登录</div>
			</div>
		</view>
	</view>
</template>

<script>
import navitop from '@/components/common/navi-top'
import {logout} from '@/common/api/table.js'
import {getUsePda} from '@/common/api/my/subpage.js'
export default {
	components:{
		navitop
	},
	data(){
		return {
			nv_height: '',
			equip_data: '',
		}
	},
	mounted() {
		this.nv_height = uni.getSystemInfoSync().statusBarHeight + 65 + 'px';
		
		this.equipment_list();
	},
	methods: {
		outlot(){
			uni.switchTab({
				url: '/pages/my/my'
			})
		},
		
		//账号安全
		set_security(){
			uni.redirectTo({
				url:'/components/user-sz/user-sz'
			})
		},
		
		// 获取默认设备
		equipment_list(){
			getUsePda().then(item => {
				if(item.code == 200){
					console.log(item)
					this.equip_data = item.data.name;
				}
			})
			if(!this.equip_data){
				this.equip_data = '默认设备：新大陆'
			}
		},
		
		// 设备选择
		set_equipment(){
			uni.navigateTo({
				url: '/pages/my/subpage/equipment_list'
			})
		},
		
		// 退出
		email_class() {
			uni.showModal({
				title: '提示',
				content: '确认退出当前账号么?',
				success: (res) => {
					if (res.confirm) {
						//用户点击确定
						logout().then(res => {
							if (res.code == 200) {
								uni.showToast({
									title: res.message,
									icon: 'none'
								});
								setTimeout(() => {
									uni.reLaunch({	
										url: '/components/user/user-dl'
									});
								}, 1500);
							}
						})
					} else if (res.cancel) {
						//用户点击取消
					}
				}
			});
		}
	}
}
</script>

<style scoped lang='scss'>
 @import '@/static/css/common/public_css.scss';
 .out_bottom{
	 width: 100%;
	 margin: auto;
	 display: flex;
	 justify-content: space-around;
 }
 .out_dologin {
	 border-radius: 4px;
	 height: 80rpx;
	 line-height: 80rpx;
	 text-align: center;
	 background-color: #0098EF;
	 color: #fff;
	 box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1);
	 width: 95%;
 }
</style>
